package com.eastmoney.emis.edda.infrastructure.edda.mapper;

import com.eastmoney.emis.datasource.annotation.TargetDataSource;
import com.eastmoney.emis.edda.common.DbName;
import com.eastmoney.emis.edda.infrastructure.edda.po.EmhkEddaApplyPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @description: Description
 * @projectName: EDDA-HSBC
 * @package: com.eastmoney.emis.edda.infrastructure.edda.mapper
 * @author: 汪程程
 * @date: 2022/10/8 9:56 AM
 * @version: 1.0
 */
@Mapper
public interface EmhkEddaApplyMapper {

    @TargetDataSource(DbName.ACCOUNT)
    void addEddaApply(@Param("clientId")String clientId, @Param("emhkEddaApplyPo")EmhkEddaApplyPo emhkEddaApplyPo);
    @TargetDataSource(DbName.ACCOUNT)
    EmhkEddaApplyPo findByEid(@Param("eid") String eid);

    @TargetDataSource(DbName.ACCOUNT)
    List<EmhkEddaApplyPo> findAllByClientId(@Param("clientId") String clientId);

    @TargetDataSource(DbName.ACCOUNT)
    List<EmhkEddaApplyPo> findAllUncompleted();

    @TargetDataSource(DbName.ACCOUNT)
    List<EmhkEddaApplyPo> findByClientIdAndBankAccount(@Param("clientId") String clientId, @Param("bankCode")String bankCode, @Param("bankAccount") String bankAccount);

    @TargetDataSource(DbName.ACCOUNT)
    EmhkEddaApplyPo findByClientIdAndRegisterId(@Param("clientId") String clientId, @Param("registerId") String registerId);

    @TargetDataSource(DbName.ACCOUNT)
    EmhkEddaApplyPo findByClientIdAndMandateIdAndStatus(@Param("clientId") String clientId, @Param("mandateId") String mandateId, @Param("status") String status);

    @TargetDataSource(DbName.ACCOUNT)
    String getEid(@Param("clientId") String clientId);

    @TargetDataSource(DbName.ACCOUNT)
    void update(@Param("clientId")String clientId, @Param("emhkEddaApplyPo")EmhkEddaApplyPo emhkEddaApplyPo);
    @TargetDataSource(DbName.ACCOUNT)
    Integer getEddaApplyTimesDailyByClientId(@Param("clientId")String clientId, @Param("applyDate") String applyDate);

    @TargetDataSource(DbName.ACCOUNT)
    Integer getEddaApplyTimesDailyByClientIdAndEITimeGreaterThan(@Param("clientId")String clientId, @Param("beginTime") LocalDateTime dateTime);


    @TargetDataSource(DbName.ACCOUNT)
    EmhkEddaApplyPo findFirstDailyByClientId(@Param("clientId")String clientId, @Param("applyDate") String applyDate);
}
